<?php

/**
 * OrgaoExterno form base class.
 *
 * @package    form
 * @subpackage orgao_externo
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 8508 2008-04-17 17:39:15Z fabien $
 */
class BaseOrgaoExternoForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'cd_orgao_externo' => new sfWidgetFormInputHidden(),
      'no_longo'         => new sfWidgetFormInput(),
      'name'             => new sfWidgetFormInput(),
      'sg_orgao_externo' => new sfWidgetFormInput(),
      'created_at'       => new sfWidgetFormDateTime(),
      'updated_at'       => new sfWidgetFormDateTime(),
      'deleted'          => new sfWidgetFormInputCheckbox(),
    ));

    $this->setValidators(array(
      'cd_orgao_externo' => new sfValidatorDoctrineChoice(array('model' => 'OrgaoExterno', 'column' => 'cd_orgao_externo', 'required' => false)),
      'no_longo'         => new sfValidatorString(array('max_length' => 255)),
      'name'             => new sfValidatorString(array('max_length' => 50)),
      'sg_orgao_externo' => new sfValidatorString(array('max_length' => 10)),
      'created_at'       => new sfValidatorDateTime(array('required' => false)),
      'updated_at'       => new sfValidatorDateTime(array('required' => false)),
      'deleted'          => new sfValidatorBoolean(),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorAnd(array(
        new sfValidatorDoctrineUnique(array('model' => 'OrgaoExterno', 'column' => array('name'))),
        new sfValidatorDoctrineUnique(array('model' => 'OrgaoExterno', 'column' => array('sg_orgao_externo'))),
      ))
    );

    $this->widgetSchema->setNameFormat('orgao_externo[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'OrgaoExterno';
  }

}
